package model;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;



public class DayPlanModel {
	private HashMap<String,Interval> schedule=new HashMap<String,Interval>();
	public static String[] days={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	
	public DayPlanModel()
	{
		for(int i=0;i<days.length;i++)
		{
			schedule.put(days[i], null);
		}
	}
	
	public Interval get(String day)
	{
		return schedule.get(day);
	}
	
	public void set(String day,Interval iv)
	{
		schedule.put(day, iv);
	}
	
	public void setSchedule(HashMap<String,Interval> schedule) {
		this.schedule = schedule;
	}

	public HashMap<String,Interval> getSchedule() {
		return schedule;
	}

	public static boolean isDay(String nodeName) {
		for(int i=0;i<days.length;i++)
			if (days[i].equals(nodeName)) return true;
			return false;
	}
	
	public String toString()
	{
		Set<String> keys=schedule.keySet();
		Iterator<String> it=keys.iterator();
		String toStr=new String("\nSchedule\n");
		while(it.hasNext())
		{
			String aux=it.next();
			Interval iv=schedule.get(aux);
			if (iv!=null) toStr+="\n"+ aux+" "+iv.toString();
		}
		return toStr;
	}
}
